<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>    
        function mySort(arr){
            var length = arr.length,
            j,temp;
            for(var i=1;i<length;i++){
                j=i; // 存下当前索引
                temp=arr[i]; //存下当前的值
                while(j>0&&arr[j-1]>temp){
                    arr[j]=arr[j-1];
                    j--;
                }
                arr[j]=temp; //j索引已经换成当时的j-1了 所以换回来
            }
            return arr;
        }
        var arr=[2,5,9,5,4,3,6,99,6,5,22,26456,6] 
        console.log(mySort(arr))
    </script>
</body>
</html>